export const materialTabs = [
    {
        type: 0,
        name: '文本',
        nameStr: 'text',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/1692847533251m1i3fenogtdhtbjn.png'
    },
    {
        type: 1,
        name: '图片',
        nameStr: 'pic',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/1692847533251m1i3fenogtdhtbjn.png'
    },
    {
        type: 2,
        name: '视频',
        nameStr: 'video',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/16928475688217hve14b7fwni5y3j.png'
    },
    {
        type: 3,
        name: '链接',
        nameStr: 'link',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/16928475907104rz6k7bbhz9gne53.png'
    },
    {
        type: 4,
        name: '音频',
        nameStr: 'audio',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/1692844697283st4m7jbhe5ubc8wj.png'
    },
    {
        type: 5,
        name: '文件',
        nameStr: 'file',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/1692847612640m6j1lat7dmwh4g49.png'
    },
    {
        type: 6,
        name: '抽奖',
        nameStr: 'luck',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/1692847730390uhdsc11zjfot6lcw.png'
    },
    {
        type: 7,
        name: '电商',
        nameStr: 'eCommerce',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/1692847742395pm4yylckrs6nk56h.png'
    },
    {
        type: 8,
        name: '电商',
        nameStr: 'eCommerce',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/1692847742395pm4yylckrs6nk56h.png'
    },
    {
        type: 9,
        name: '收集表',
        nameStr: 'collect',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/1692847763022p8czsni83cgs4x7o.png'
    },
    {
        type: 10,
        name: '公众号',
        nameStr: 'officialAccounts',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/16928477807777sj6xeh713jr4kw9.png'
    },
    {
        type: 11,
        name: '小程序',
        nameStr: 'miniProgram',
        icon: 'https://img.static-keyid.cn/toolspace/scrm/2023/08/1692847795359f7kfa6jc8ro3efeo.png'
    }
];

/**
 * 文件类型
 */
const fileTypeInfo = {
    '.pdf': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670428984w9l1jcqbkx65vk7f.png',
    '.doc': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/16946704390141w0c34wob54kf7p9.png',
    '.docx': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/16946704390141w0c34wob54kf7p9.png',
    '.xls': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670467878fhgigxlsz9luwwp6.png',
    '.xlsx': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670467878fhgigxlsz9luwwp6.png',
    '.ppt': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670482261qbckz0yiadabpo7v.png',
    '.pptx': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670482261qbckz0yiadabpo7v.png',
    '.png': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670496752ytir0j1cdpff4wym.png',
    '.jpg': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670496752ytir0j1cdpff4wym.png',
    '.jpeg': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670496752ytir0j1cdpff4wym.png',
    '.text': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670511980clgmgxz8ixla8v9n.png',
    '.txt': 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670511980clgmgxz8ixla8v9n.png'
};

const fileDefaultImg = 'https://img.static-keyid.cn/toolspace/scrm/2023/09/1694670655931coq4464iapuyeczr.png';

/**
 * @description: 欢迎语 选择素材组件 映射 map对象
 * @param {*} any
 * @return {*}
 */
export const getHashTabs = () => {
    return materialTabs.reduce((pre, cur) => {
        return { ...pre, [cur.type]: cur };
    }, {});
};

/**
 * 更具文件名类型获取对应图标
 * @param str
 * @returns
 */
export const getSuffixIcon = str => {
    if (str) {
        const suffix = str.substring(str.lastIndexOf('.'));
        const types = Object.keys(fileTypeInfo);
        if (types.includes(suffix)) {
            return fileTypeInfo[suffix];
        } else {
            return fileDefaultImg;
        }
    } else {
        return fileDefaultImg;
    }
};
